<?php
if (!defined('FosfoaSystem')) { exit(1);}
class news_commentsModel extends spModel
{
	var $pk = "news_comments_id"; // 每个唯一的标志，可以称为主键
	var $table = "news_comments"; // 数据表的名称
    
    /**
     * 获取单条评论
     */
    function Detail($news_comments_id){
		$condition = array('news_comments_id'=>$news_comments_id);
		$arr = $this->find($condition);
		return $arr;
	}
    /**
     * 判断信息是否有评论
     */
    function ispl($news_id){
		$condition = array('news_id'=>$news_id);
		$arr = $this->find($condition);
		return $arr;
	}
    /**
     * 获取最新信息评论
     * @param $num 条数
     */
    function comment_news_list($num=10)
    {
        if(PLSH=='1') $condition=array('news_id'=>$news_id,'type'=>1);
		$arr = $this->spCache(3600 * 24)->findAll($condition,'news_comments_id DESC',NULL,$num);
		return $arr; 
    }
    /**
     * 获取指定信息ID的所有评论
     */
    function GetCommentsList($news_id)
    {
		$condition = array('news_id'=>$news_id);
        if(PLSH=='1') $condition=array('news_id'=>$news_id,'type'=>1);
		$arr = $this->spCache(3600 * 24)->findAll($condition);
		return $arr;
    }
    /**
     * 保存信息评论
     */
    function SaveComment($data)
    {
        if(!is_array($data))return false;
        $this->create($data);
        return true;
    }
}